﻿using System;
using System.Net;
using System.ComponentModel;

namespace FbHelperWP7NonUi.BookStorage.DropBoxStorage.AsyncHelpClasses
{
    internal delegate void AsyncRequestCompleted<T>( T t ) where T : AbstractAsyncResult;

    internal abstract class AbstractAsyncResult
    {
        private readonly Exception error;
        private readonly BackgroundWorker worker;

        public AbstractAsyncResult( AbstractAsyncData data, Exception error = null )
        {
            this.error = error;
            this.worker = data.Worker;
        }

        public Exception Error
        {
            get
            {
                return error;
            }
        }

        public BackgroundWorker Worker
        {
            get
            {
                return worker;
            }
        }

        public bool IsSuccess
        {
            get
            {
                return error == null;
            }
        }
    }
}
